<%@page import="shop.vo.ProductBean"%>
<%@page import="shop.vo.OrderProBean"%>
<%@page import="shop.vo.OrderBean"%>
<%@page import="java.util.Iterator"%>
<%@page import="shop.factory.DAOFactory"%>
<%@page import="shop.vo.UserBean"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../css/bootstrap.min.css">
<script src="../js/jquery-1.10.2.min.js" type="text/javascript"
	charset="utf-8"></script>
<script type="text/javascript" src="../js/bootstrap.min.js"></script>
<title>查看订单</title>
<style type="text/css">
<!--
.style1 {
	color: #00CCFF
}

th,td{
		text-align: center;
	}

a {
	text-decoration: none;
	color: #00CCFF;
}

a:hover {
	color: red;
}
-->
</style>
</head>
<%
	if (!(boolean)session.getAttribute("adminLogin")) {
		String path = request.getContextPath() + "/Admin/login.jsp";
		response.sendRedirect(path);
	}
%>
<body>
	<div class="container-fluid">
		<h3>订单管理</h3>
		<div class="page-header" style="margin-top:10px;"></div>
		<form action="<%=request.getContextPath() %>/OrderServlet" method="post">
		<input type="hidden" name="action" value="orderdelete">
		<table class="table table-bordered table-condensed table-striped">
				<tr>
					<th>多选</th>
					<th>订单号</th>
					<th>客户名称</th>
					<th>手机</th>
					<th>电话</th>
					<th>真实姓名</th>
					<th>邮编</th>
					<th>地址</th>
					<th>商品名称</th>
					<th>商品单价</th>
					<th>购买数量</th>
					<th>商品总价</th>
					<th>订单日期</th>
					<th>订单状态</th>
					<th>操作</th>
				</tr>
				<%
					int nowPage = 1;
					int pageSize = 10;
					String str = request.getParameter("to");
					if (str != null) {
						nowPage = Integer.parseInt(str);
					}
					int up = nowPage;
					int next = nowPage;
					int maxPage = 0;
					int count = DAOFactory.getIOrderDAOInstance().getCount();
					if (count % pageSize == 0) {
						maxPage = count / pageSize;
					} else {
						maxPage = (count / pageSize) + 1;
					}
					if (next < maxPage) {
						next += 1;
					}
					if (up > 1) {
						up -= 1;
					}
					List<OrderProBean> list = DAOFactory.getIOrderProDAOInstance().list(nowPage, pageSize);
					Iterator<OrderProBean> it = list.iterator();
					while (it.hasNext()) {
						OrderProBean orderpro = it.next();
						OrderBean order = orderpro.getOrder();
						ProductBean product = orderpro.getProduct();
						UserBean user = order.getUser();
						int state = order.getOrder_state();
						String str0 = null;
						switch (state) {
							case 1:
								str0 = "未处理";
								break;
							case 2:
								str0 = "已备货";
								break;
							case 3:
								str0 = "已发货";
								break;
							case 4:
								str0 = "已完成";
								break;
							default:
								break;
						}
				%>
				<tr class="warning">
					<td><input type="checkbox"
						value="<%=order.getOrder_id()%>" id="cheboxId" name="cheboxId"></td>
					<td><%=order.getOrder_id()%></td>
					<td><%=user.getUser_name()%></td>
					<td><%=user.getUser_mobile()%></td>
					<td><%=user.getUser_phone()%></td>
					<td><%=user.getUser_truename()%></td>
					<td><%=user.getUser_zip()%></td>
					<td><%=user.getUser_addr()%></td>
					<td><%=product.getPro_name()%></td>
					<td><%=product.getPrice()%></td>
					<td><%=orderpro.getNum()%></td>
					<td><%=orderpro.getPrice()%></td>
					<td><%=order.getOrder_time()%></td>
					<td><%=str0%></td>
					<td><a href="updateorder.jsp?order_id=<%=order.getOrder_id()%>">修改</a></td>
				</tr>
				<%
					}
				%>
				<tr>
					<td align="center" colspan="15"><input type="button"
						value="全选" onclick="quan()">&nbsp;&nbsp;&nbsp;&nbsp;<input
						type="button" value="反选" onclick="fan()">&nbsp;&nbsp;&nbsp;&nbsp;<input
						type="reset" value="重置">&nbsp;&nbsp;&nbsp;&nbsp;<input
						type="submit" value="删除" onclick="return confirm('是否删除？')"></td>
				</tr>
				<tr>
					<td colspan="15" align="center"><span class="style1"> <a
							href="orderList.jsp?to=1">首页</a>&nbsp;|&nbsp; <a
							href="orderList.jsp?to=<%=up%>">上一页</a>&nbsp;|&nbsp;<a
							href="orderList.jsp?to=<%=next%>">下一页</a>&nbsp;|&nbsp; <a
							href="orderList.jsp?to=<%=maxPage%>">尾页</a>
					</span> &nbsp;&nbsp;第&nbsp;<%=nowPage%>&nbsp;页/共&nbsp;<%=maxPage%>&nbsp;页</td>
				</tr>
			</table>
		</form>
	</div>
</body>
<script type="text/javascript">
	function quan() {
		var checkObj = document.all("cheboxId");
		for (var i = 0; i < checkObj.length; i++) {
			checkObj[i].checked = true;
		}
	}
	function fan() {
		var checkObj = document.all("cheboxId");
		for (var i = 0; i < checkObj.length; i++) {
			if (checkObj[i].checked == true)
				checkObj[i].checked = false;
			else
				checkObj[i].checked = true;
		}
	}
</script>
</html>


